package acp

const (
	ClusterViewUrlPath = "/apis/cluster.alauda.io/v1/namespaces/cpaas-system/clusterviews"
)

func (c *Controller) GetArchitectures(archs []string) ([]string, error) {
	archList := make([]string, 0, len(archs))
	clusterViewUrl := c.Host + ClusterViewUrlPath
	for _, arch := range archs {
		cvl := new(ClusterViewList)
		_, err := c.R().
			SetAuthToken(c.Option.Token).
			SetQueryParam("limit", "1").
			SetQueryParam("labelSelector", "cpaas.io/arch="+arch).
			SetResult(cvl).
			Get(clusterViewUrl)
		if err != nil {
			return nil, err
		}
		if len(cvl.Items) > 0 {
			archList = append(archList, arch)
		}
	}
	return archList, nil
}
